CC = m68k-palmos-gcc
DEBUGCFLAGS= -g -DDEBUG_BUILD
RELEASECFLAGS= -O2
# change following from DEBUGCFLAGS to RELEASECFLAGS for a no-debug build
CFLAGS = -palmos5r3 $(DEBUGCFLAGS)
#change the following line to change the name of the built project
# make sure you also change the name of the .def file to match
APP=OReillyStarter

SRCDIR=Src/
OUTPUTDIR=GCC/
RCPFILE=Resources.rcp

OBJS=$(OUTPUTDIR)Main.o $(OUTPUTDIR)Utils.o $(OUTPUTDIR)MainForm.o $(OUTPUTDIR)SecondForm.o

$(OUTPUTDIR)$(APP).prc: $(OUTPUTDIR)$(APP) $(OUTPUTDIR)bin.stamp $(APP).def
	build-prc $(APP).def $(OUTPUTDIR)$(APP) -o $(OUTPUTDIR)$(APP).prc  $(OUTPUTDIR)*.bin

$(OUTPUTDIR)$(APP): $(OBJS)
	$(CC) $(CFLAGS) -o $@ $(OBJS)

$(OUTPUTDIR)%.o: $(SRCDIR)%.c 
	$(CC) $(CFLAGS) -c $< -o $@

$(OBJS): $(SRCDIR)ResourceDefines.h $(SRCDIR)Utils.h

$(OUTPUTDIR)Main.o $(OUTPUTDIR)MainForm.o: $(SRCDIR)MainForm.h 

$(OUTPUTDIR)Main.o $(OUTPUTDIR)SecondForm.o: $(SRCDIR)SecondForm.h 

$(OUTPUTDIR)bin.stamp: $(SRCDIR)$(RCPFILE) $(SRCDIR)ResourceDefines.h
	( cd $(OUTPUTDIR); rm *.bin; pilrc -I ../$(SRCDIR) ../$(SRCDIR)$(RCPFILE))
	touch $(OUTPUTDIR)/bin.stamp


clean:
	rm -f $(OBJS) $(OUTPUTDIR)$(APP) $(OUTPUTDIR)*.bin $(OUTPUTDIR)bin.stamp
